package com.dream.jump.room

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
class DatabaseModule {

    @Provides
    @Singleton
    fun provideDatabaseClient(@ApplicationContext context: Context) =
        Room.databaseBuilder(context, DatabaseClient::class.java, "jump.db").build()

    @Provides
    fun provideUserDao(database: DatabaseClient) = database.userDao()

    @Provides
    fun provideTypeDao(database: DatabaseClient) = database.typeDao()
}